package com.atguigu.controller;

import com.atguigu.service.UserService;
import com.atguigu.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * projectName: javaweb
 *
 * @author: 赵伟风
 * time: 2022/7/4 17:14 周一
 * description: 用户删除的controller
 */
@WebServlet("/user/remove")
public class UserRemoveController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //0. 设置编码格式
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //1. 接收前端参数
        String id = req.getParameter("id");
        //2. 编写业务逻辑
        UserService userService = new UserServiceImpl();
        userService.remove(id);

        //3. 响应前端数据
        //转发 到有到用户展示的controller
        req.getRequestDispatcher("/user/show").forward(req,resp);
    }

}
